/*
 * @Author: wangqizhang
 * @Date: 2024-05-02 16:32:36
 * @LastEditors: wangqizhang
 * @LastEditTime: 2024-05-12 16:46:23
 * @FilePath: /suixinji-server/controller/group.controller.js
 * @Description:
 *
 * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved.
 */
const querystring = require('querystring');
const {
  findAll,
  addData,
  updateData,
  findDataByQuery,
} = require('../service/group.service.js');
const { dealResponse } = require('../until/index.js');
class GroupController {
  async getList(ctx, next) {
    const res = await findAll(ctx);
    dealResponse(ctx, res);
  }
  async add(ctx, next) {
    ctx.request.body.user_id = ctx.state.user.id;
    const res = await addData(ctx.request.body);
    dealResponse(ctx, res);
  }
  async update(ctx, next) {
    const res = await updateData(ctx.request.body);
    dealResponse(ctx, res);
  }
  async getListByQuery(ctx, next) {
    ctx.request.body.where.user_id = ctx.state.user.id;
    ctx.request.request.body.offset -= 1;
    const res = await findDataByQuery(ctx);
    dealResponse(ctx, res);
  }
}
module.exports = new GroupController();
